<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<script src="js/tools.js"></script>
		<style type="text/css">
			*{
				margin: 0;
				padding: 0;
			}
			#outer{
				position: relative;
				width: 520px;
				height: 333px;
				background-color: pink;
				margin: 50px auto;
				padding: 10px 0;
				overflow: hidden;
			}
			
			#imgList{
				list-style: none;
				
				position: absolute;
			}
			
			#imgList li{
				float: left;
				
				margin: 0 10px;
			}
			
			#navDiv{
				position: absolute;
				
				bottom: 15px;
			}
			
			#navDiv a{
				float: left;
				width: 15px;
				height: 15px;
				background-color: lawngreen;
				margin: 0 5px;
				opacity: 50%;
				filter: alpha(opacity=50);
			}
		</style>
		
		<script type="text/javascript">
			window.onload = function(){
				var imgList = document.getElementById("imgList");
				
				var imgArr = document.getElementsByTagName("img");
				
				imgList.style.width = 520 * imgArr.length + "px";
				
				var navDiv = document.getElementById("navDiv");
				
				var outer = document.getElementById("outer");
				
				var allA = document.getElementsByTagName("a");
				
				navDiv.style.left = (outer.offsetWidth - navDiv.offsetWidth) / 2 + "px";
				
				
				var index = 0;
				
				allA[index].style.backgroundColor = "black";
				
				
				for(var i=0; i<allA.length; i++){
					allA[i].num = i;
					
					allA[i].onclick = function(){
						
						clearInterval(timer);
						
						index = this.num;
						
						setA();
						
						move(imgList , "left" , -520*index , 20 ,function(){
							autoChange();
						});
					};
				}
				
				autoChange();
				
				function setA(){
					
					if(index >= imgArr.length - 1){
						
						index = 0;
						
						imgList.style.left = 0;
					}
					for(var i=0; i<allA.length;i++){
						allA[i].style.backgroundColor = "";
					}
						allA[index].style.backgroundColor = "black";
					
				}
				
				var timer;
				
				function autoChange(){
					
					timer  = setInterval(function(){
						index++;
						
						index %= imgArr.length;
						
						move(imgList , "left" , -520*index , 20 ,function(){
							
							setA();
							
						});
						
					},3000);
				}
			};
		</script>
	</head>
	<body>
		<div id="outer">
			<ul id="imgList">
				<li><img src="img/dl.jpg" /></li>
				<li><img src="img/1.jpg" /></li>
				<li><img src="img/2.jpg" /></li>
				<li><img src="img/3.jpg" /></li>
				<li><img src="img/4.jpg" /></li>
				<li><img src="img/5.jpg" /></li>
				<li><img src="img/dl.jpg" /></li>
				
			</ul>
			
			<div id="navDiv">
				<a href="javascript:;"></a>
				<a href="javascript:;"></a>
				<a href="javascript:;"></a>
				<a href="javascript:;"></a>
				<a href="javascript:;"></a>
				<a href="javascript:;"></a>
			</div>
		</div>
	</body>
</html>
